package JDBC_learn;

import org.junit.Test;

import java.sql.*;

public class JDBCDemo6 {
   @Test
     public void JDBCDemo_userlogin() throws Exception {
       String url = "jdbc:mysql:///itheima?useSSL=false";
       String username = "root";
       String password = "11235813";
       Connection conn = DriverManager.getConnection(url, username, password);
     //接收用户输入，用户名和密码
       String name="魏正想";
       String pwd="11235813";
       String sql="select*from tb_user where name='"+name+"'and password='"+pwd+"'";
         Statement stmt = conn.createStatement();
       ResultSet rs=stmt.executeQuery(sql);
       if(rs.next()){
           System.out.println("登陆成功");
       }else {
           System.out.println("登陆失败");
       }
         rs.close();
         stmt.close();
         conn.close();

     }
}
